﻿using System;
using ASPNETVN.PORTAL.Components.Configuration.Settings;
using ASPNETVN.PORTAL.Components.UI;
using System.Collections;
using ASPNETVN.PORTAL.Components.UI.DataTypes;

namespace ASPNETVN.PORTAL.Modules.IFRAME
{
    public partial class Main : PortalModuleControl
    {
        public Main()
        {

            ModuleSettingItem itemSetting = new ModuleSettingItem(new StringDataType());
            itemSetting.Value = "";
            itemSetting.Name = "CssClass";
            itemSetting.Description = "CssClass";
            itemSetting.SortOrder = 1;
            this.BaseSettings.Add("CssClass", itemSetting);

            itemSetting = new ModuleSettingItem(new StringDataType());
            itemSetting.Value = "400";
            itemSetting.Name = "FrameHeight";
            itemSetting.Description = "FrameHeight";
            itemSetting.SortOrder = 2;
            this.BaseSettings.Add("FrameHeight", itemSetting);

            itemSetting = new ModuleSettingItem(new StringDataType());
            itemSetting.Value = "400";
            itemSetting.Name = "FrameWidth";
            itemSetting.Description = "FrameWidth";
            itemSetting.SortOrder = 3;
            this.BaseSettings.Add("FrameWidth", itemSetting);

            itemSetting = new ModuleSettingItem(new StringDataType());
            itemSetting.Value = "0";
            itemSetting.Name = "FrameBorder";
            itemSetting.Description = "FrameBorder";
            itemSetting.SortOrder = 4;
            this.BaseSettings.Add("FrameBorder", itemSetting);

            itemSetting = new ModuleSettingItem(new StringDataType());
            itemSetting.Value = "auto";
            itemSetting.Name = "Scrolling";
            itemSetting.Description = "Scrolling";
            itemSetting.SortOrder = 5;
            this.BaseSettings.Add("Scrolling", itemSetting);

            itemSetting = new ModuleSettingItem(new StringDataType());
            itemSetting.Value = "";
            itemSetting.Name = "FrameSource";
            itemSetting.Description = "FrameSource";
            itemSetting.SortOrder = 6;
            this.BaseSettings.Add("FrameSource", itemSetting);
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            Hashtable settings = this.Settings;
            iframe.Attributes.Add("class", settings["CssClass"].ToString());
            iframe.Attributes.Add("height", settings["FrameHeight"].ToString());
            iframe.Attributes.Add("width", settings["FrameWidth"].ToString());
            iframe.Attributes.Add("frameborder", settings["FrameBorder"].ToString());
            iframe.Attributes.Add("scrolling", settings["Scrolling"].ToString());
            iframe.Attributes.Add("src", settings["FrameSource"].ToString());
        }
    }
}